var e = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../../utils/config.js")), t = require("../../utils/api.js"), a = require("../../utils/util.js"), o = (require("../../wxParse/wxParse.js"), 
require("../../utils/wxApi.js"), require("../../utils/wxRequest.js"));

e.default.getPageCount, getApp();

Page({
    data: {
        title: "最新评论列表",
        showerror: "none",
        showallDisplay: "block",
        readLogs: []
    },
    onShareAppMessage: function() {
        return {
            title: "分享" + e.default.getWebsiteName + "的最新评论",
            path: "pages/comments/comments",
            success: function(e) {},
            fail: function(e) {}
        };
    },
    reload: function(e) {
        var t = this;
        this.setData({
            readLogs: []
        }), t.setData({
            showallDisplay: "none",
            showerror: "none"
        }), t.fetchCommentsData();
    },
    onLoad: function(e) {
        this.fetchCommentsData();
    },
    onShow: function(e) {},
    fetchCommentsData: function() {
        var e = this, s = this;
        wx.showLoading({
            title: "正在加载",
            mask: !0
        }), o.getRequest(t.getNewComments()).then(function(t) {
            200 == t.statusCode ? (e.setData({
                readLogs: s.data.readLogs.concat(t.data.map(function(e) {
                    return e[0] = e.post, e[1] = a.removeHTML(e.content.rendered + "(" + e.author_name + ")"), 
                    e[2] = "0", e;
                }))
            }), s.setData({
                showallDisplay: "block"
            })) : (console.log(t), e.setData({
                showerror: "block"
            }));
        }).catch(function() {
            s.setData({
                showerror: "block",
                floatDisplay: "none"
            });
        }).finally(function() {
            wx.hideLoading();
        });
    },
    redictDetail: function(e) {
        var t = "../detail/detail?id=" + e.currentTarget.id;
        wx.navigateTo({
            url: t
        });
    },
    onPullDownRefresh: function() {
        var e = this;
        this.setData({
            readLogs: []
        }), e.setData({
            showallDisplay: "none",
            showerror: "none"
        }), e.fetchCommentsData(), wx.stopPullDownRefresh();
    }
});